cmake_minimum_required(VERSION 2.8.3)
project(reconstruction)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

find_package(catkin REQUIRED 
roscpp rospy rosbag std_msgs geometry_msgs nav_msgs
tf tf2 tf_conversions message_filters map_msgs libpointmatcher_ros visualization_msgs
interactive_markers ethzasl_gridmap_2d message_generation libpointmatcher roslib cv_bridge
pcl_ros pcl_conversions
)
find_package(libnabo)

set(EIGEN3_INCLUDE_DIR /usr/include/eigen3)
find_package(Eigen3 )
set( ENV{FLANN_ROOT} /usr/include )
find_package(PCL REQUIRED)
find_package(VTK REQUIRED)
# find_package(Glog REQUIRED)

find_package(Boost COMPONENTS thread) 


find_package(OpenCV 3 QUIET)
if(NOT OpenCV_FOUND)
   find_package(OpenCV 2.4.3 QUIET)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
   endif()
endif()
message(recon:${catkin_INCLUDE_DIRS})


generate_messages(DEPENDENCIES sensor_msgs nav_msgs std_msgs geometry_msgs actionlib_msgs)


catkin_package (
	CATKIN_DEPENDS roscpp rospy rosbag std_msgs geometry_msgs nav_msgs
tf tf2 tf_conversions message_filters map_msgs libpointmatcher_ros ethzasl_gridmap_2d visualization_msgs interactive_markers 
message_runtime libpointmatcher libnabo roslib pcl_ros pcl_conversions

)

# set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(CMAKE_BUILD_TYPE Release)

#else some functions cannot be used
if(CMAKE_COMPILER_IS_GNUCXX)
	execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
	if (GCC_VERSION VERSION_GREATER 4.4 OR GCC_VERSION VERSION_EQUAL 4.4)
		add_definitions(-std=gnu++0x)
	else (GCC_VERSION VERSION_GREATER 4.4 OR GCC_VERSION VERSION_EQUAL 4.4)
		message(SEND_ERROR "You need GCC version 4.4 or greater to compile this library")
	endif (GCC_VERSION VERSION_GREATER 4.4 OR GCC_VERSION VERSION_EQUAL 4.4)
else(CMAKE_COMPILER_IS_GNUCXX)
	message(SEND_ERROR "You need partial C++0x support for N2351, N2672, N1984. Currently this build toolchain supports only GCC >= 4.4. If your compiler supports these specifications, please send us a patch.")
endif(CMAKE_COMPILER_IS_GNUCXX)



add_definitions(-DHAVE_YAML_CPP)
# add_definitions(-std=c++11 -O3 -g -DNDEBUG)
add_definitions(-std=c++11 -O3)

include_directories(
include

${OpenCV_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${GLOG_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)

include_directories( "src/elas" )
include_directories( "src/Pano" )
include_directories( "src/mypcl" )

# find_package(PCL REQUIRED)
# link_directories(${PCL_LIBRARY_DIRS})
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_library(
    pcl_bridge 
    src/mypcl/pcl_bridge.cpp
)

target_link_libraries(
    pcl_bridge
    ${PCL_LIBRARIES}
)

add_executable(reconstruction
	src/reconstruction.cpp
# 	src/Pano/Pano.cpp
# 	src/elas/elas.cpp
# 	src/elas/matrix.cpp
# 	src/elas/descriptor.cpp
# 	src/elas/triangle.cpp
# 	src/elas/filter.cpp
)

add_dependencies(reconstruction ${PROJECT_NAME}_gencpp)
target_link_libraries(reconstruction
${EIGEN3_LIBS}
${GLOG_LIBRARIES}
${Boost_LIBRARIES}
${OpenCV_LIBS}
pcl_bridge
${catkin_LIBRARIES}
)

install(
  TARGETS
  reconstruction
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)

install(
  DIRECTORY config launch data
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)


